const Sequelize = require('sequelize');
var appConfig = require('@root/config.js');


var sequelize = new Sequelize({
    database: appConfig.mysqlDatabase,          //数据库名称
    username: appConfig.mysqlUsername,        //数据库用户名
    password: appConfig.mysqlPassword,       //数据库密码
    host: appConfig.mysqlHost,         //数据库主机IP  localhost
    dialect: 'mysql',
    freezeTableName: false,
    define: {
        raw: true,
        'underscored': true,
        'charset': 'utf8mb4'
    },
    timezone: "+08:00",
    pool: {
        max: 5,
        min: 0,
        idle: 30000
    },
    logging: false
});
sequelize.authenticate().then(() => {

}).catch(err => {
    console.error('mysql link error', err);
});

var initModels  = require('./models/init-models')
var Models = initModels(sequelize)
module.exports = Models
